package com.companion.companion.controller;

import java.util.List;

import com.companion.companion.domain.Conversation;
import com.companion.companion.service.IConversationService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;


/**
 * 用户与护工之间的会话Controller
 * 
 * @author zly
 * @date 2025-05-06
 */@CrossOrigin
@RestController
@RequestMapping("/system/conversation")
public class ConversationController
{
    @Autowired
    private IConversationService conversationService;

    /**
     * 查询用户与护工之间的会话列表
     */
    @GetMapping("/list")
    public List<Conversation> list(Conversation conversation)
    {
        return conversationService.selectConversationList(conversation);
    }

    /**
     * 获取用户与护工之间的会话详细信息
     */
    @GetMapping(value = "/{conversationId}")
    public Conversation getInfo(@PathVariable("conversationId") Long conversationId)
    {
        return conversationService.selectConversationByConversationId(conversationId);
    }

    /**
     * 新增用户与护工之间的会话
     */
    @PostMapping
    public int add(@RequestBody Conversation conversation)
    {
        return conversationService.insertConversation(conversation);
    }

    /**
     * 修改用户与护工之间的会话
     */
    @PutMapping
    public int edit(@RequestBody Conversation conversation)
    {
        return conversationService.updateConversation(conversation);
    }

    /**
     * 删除用户与护工之间的会话
     */
    @DeleteMapping("/{conversationIds}")
    public int remove(@PathVariable Long[] conversationIds)
    {
        return conversationService.deleteConversationByConversationIds(conversationIds);
    }
}
